﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Command;
using JustinAngel.Neurons.Framework;
using JustinAngel.Neurons.Framework.Navigation;
using JustinAngel.UnitedNationsNews.AppCore;
using Newtonsoft.Json;

namespace JustinAngel.UnitedNationsNews.ItemViewMoels
{
    [JsonObject(MemberSerialization.OptIn)]
    public class SectionViewModel : VViewModelBase
    {
        public SectionViewModel()
        {
        }

        public SectionViewModel(string displayName, string rssName) : this(displayName, rssName, displayName)
        {
        }

        public SectionViewModel(string displayName, string rssName, string imageName)
        {
            DisplayName = displayName;
            RssName = rssName;
            ImageUri = new Uri("/Pages/Main/Assets/" + imageName + ".jpg", UriKind.Relative);
        }

        [JsonProperty]
        public string DisplayName { get; set; }
        [JsonProperty]
        public string RssName { get; set; }
        [JsonProperty]
        public Uri ImageUri { get; set; }

        public ICommand GoToSection
        {
            get
            {
                return new RelayCommand(() => 
                    MessengerInstance.Send(new NavigateToMessage(PageSources.SectionPage, this))    
                );
            }
        }

        private List<ArticleItemViewModel> _articles;
        [JsonProperty]
        public List<ArticleItemViewModel> ArticleViewModels
        {
            get { return _articles; }
            set
            {
                _articles = value;
                RaisePropertyChanged(() => ArticleViewModels);
            }
        }

        public ICommand NavigateToSection
        {
            get
            {
                return new RelayCommand(() =>
                    MessengerInstance.Send(new NavigateToMessage(PageSources.SectionPage, this)));
            }
        }
    }
}
